package com.tjhk.demo.taos.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tjhk.demo.taos.entity.Location;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface LocationMapper extends BaseMapper<Location> {

    List<Location> selectListInTable(@Param("tableName")String tableName
            ,@Param("stTime")String stTime
            ,@Param("endTime")String endTime);

    int insertOneTest(Map<String,Object> map);

    int batchInsertTest(@Param("tableName")String tableName ,@Param("plateNo")String plateNo ,@Param("list") List<Location> list);

    int insertOne(Map<String,Object> map);

    int batchInsert(@Param("tableName")String tableName ,@Param("plateNo")String plateNo ,@Param("list") List<Location> list);

    @Update("drop table if exists #{tableName};")
    void dropTable(String tableName);

    @Update("CREATE STABLE `stb_locations` (`st` TIMESTAMP, `speed` FLOAT, `angle` INT, `altitude` INT, `mileage` INT, `acc_status` INT, `longitude` DOUBLE, `latitude` DOUBLE) TAGS (`plate_no` VARCHAR(20));")
    Void createTable();
}
